package com.hemerasolutions.v2trainer.model.training;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.hemerasolutions.v2trainer.model.base.BaseModel;
import com.hemerasolutions.v2trainer.model.exercise.PhysicalCapacity;
import com.hemerasolutions.v2trainer.model.exercise.executions.AssociationET;
import com.hemerasolutions.v2trainer.model.unit.volume.VolumeType;


@Entity
public class TrainingType extends BaseModel {
 
	private static final long serialVersionUID = 1L;

    @Column(length = 50)
	private String name;

    @ManyToOne
    private VolumeType intensityVolume;    
    
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "trainingType", orphanRemoval=true , 
		 cascade = CascadeType.ALL )
	private List<AssociationET> associationETs;
	
    @ManyToMany
    private List<VolumeType> volumeTypes;
    
    @ManyToMany
    private List<PhysicalCapacity> physicalCapacitys;

    public TrainingType() {
		super();
		this.physicalCapacitys = new ArrayList<PhysicalCapacity>();
		this.associationETs = new ArrayList<AssociationET>();
		this.volumeTypes = new ArrayList<VolumeType>();
	}

	public String getName() {
		return name;
	}

	public List<AssociationET> getAssociationETs() {
		return associationETs;
	}

	public List<VolumeType> getVolumeTypes() {
		return volumeTypes;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setAssociationETs(List<AssociationET> associationETs) {
		this.associationETs = associationETs;
	}

	public void setVolumeTypes(List<VolumeType> volumeTypes) {
		this.volumeTypes = volumeTypes;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	
	public List<PhysicalCapacity> getPhysicalCapacitys() {
		return physicalCapacitys;
	}

	public void setPhysicalCapacitys(List<PhysicalCapacity> physicalCapacitys) {
		this.physicalCapacitys = physicalCapacitys;
	}
	
	public VolumeType getIntensityVolume() {
		return intensityVolume;
	}

	public void setIntensityVolume(VolumeType intensityVolume) {
		this.intensityVolume = intensityVolume;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((intensityVolume == null) ? 0 : intensityVolume.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		TrainingType other = (TrainingType) obj;
		if (id == null) {
			if (other.id != null) {
				return false;
			}
		} else if (!id.equals(other.id)) {
			return false;
		}
		if (intensityVolume == null) {
			if (other.intensityVolume != null) {
				return false;
			}
		} else if (!intensityVolume.equals(other.intensityVolume)) {
			return false;
		}
		if (name == null) {
			if (other.name != null) {
				return false;
			}
		} else if (!name.equals(other.name)) {
			return false;
		}
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "TrainingType [id=" + id + ", name=" + name
				+ ", intensityVolume=" + intensityVolume + "]";
	}


	
}
 
